package com.leaf.u_spring.chapter03;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;

@Configuration
@PropertySource("classpath:/conf/app.properties")		//声明属性源
public class ExpressiveConfig {

	@Autowired
	Environment env;
	
	@Bean
	public BlankDisc disc(){
		return new BlankDisc(env.getProperty("disc.title"),
				env.getProperty("disc.artist"));
	}
	
	/**
	 * 能够基于Environment及其属性源解析占位符
	 * @return
	 */
	@Bean
	public static PropertySourcesPlaceholderConfigurer placeholderConfigurer(){
		return new PropertySourcesPlaceholderConfigurer();
	}
	
}
